﻿<!doctype html>
<html class="no-js" lang="zxx">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Addina - 网上图书商城</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="../../imgs/favicon.png">
    <link rel="stylesheet" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" href="../../css/meanmenu.min.css">
    <link rel="stylesheet" href="../../css/animate.css">
    <link rel="stylesheet" href="../../css/swiper.min.css">
    <link rel="stylesheet" href="../../css/slick.css">
    <link rel="stylesheet" href="../../css/magnific-popup.css">
    <link rel="stylesheet" href="../../css/fontawesome-pro.css">
    <link rel="stylesheet" href="../../css/spacing.css">
    <link rel="stylesheet" href="../../css/main.css">
</head>
<body>
<div id="preloader">
    <div class="bd-loader-inner">
        <div class="bd-loader"><span class="bd-loader-item"></span><span class="bd-loader-item"></span><span
                class="bd-loader-item"></span><span class="bd-loader-item"></span><span
                class="bd-loader-item"></span><span class="bd-loader-item"></span><span
                class="bd-loader-item"></span><span class="bd-loader-item"></span></div>
    </div>
</div>
<div class="backtotop-wrap cursor-pointer">
    <svg class="backtotop-circle svg-content" width="100%" height="100%" viewbox="-1 -1 102 102">
        <path d="M50,1 a49,49 0 0,1 0,98 a49,49 0 0,1 0,-98"></path>
    </svg>
</div>
<div class="df-search-area">
    <div class="container">
        <div class="row">
            <div class="col-xl-12">
                <div class="df-search-form">
                    <div class="df-search-close text-center mb-20">
                        <button class="df-search-close-btn df-search-close-btn"></button>
                    </div>
                    <form action="#">
                        <div class="df-search-input mb-10"><input type="text" placeholder="Search for product...">
                            <button type="submit"><i class="flaticon-search-1"></i></button>
                        </div>
                        <div class="df-search-category"><span>Search by:</span><a href="#">Healthline,</a><a href="#">COVID-19,</a><a
                                href="#">Surgery,</a><a href="#">Surgeon,</a><a href="#">Medical research</a></div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="body-overlay"></div>
<header>
    <div class="header">
        <div class="header-top-area grocery__top-header">
            <div class="header-layout-4">
                <div class="header-to-main d-none d-sm-flex">
                    <div class="link-text"><span><img src="../../imgs/icons/call.png" alt=""></span><a
                            href="">4001066666-5</a></div>
                    <div class="header-top-notice d-none d-lg-block">
                        <p>热烈庆祝新店开业！为答谢广大顾客的支持与厚爱，特推出限时折扣活动，优惠多多，不容错过！</p>
                    </div>
                    <div class="tp-header-top-menu d-flex align-items-center justify-content-end">
                        <div class="header-lang-item tp-header-setting">
                            <ul>
                                <li><a class="furniture-clr-hover" href="/url/info">个人信息</a></li>
                                <li><a class="furniture-clr-hover" href="/url/cart">购物车</a></li>
                                <li><a class="furniture-clr-hover" href="/url/login">退出登录</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="header-layout-4 header-bottom">
            <div id="header-sticky" class="header-4">
                <div class="mega-menu-wrapper">
                    <div class="header-main-4">
                        <div class="header-left">
                            <div class="header-logo"><a href="/url/index"><img src="../../imgs/furniture/logo/logo.svg"
                                                                               alt="logo not found"></a></div>
                            <div class="mean__menu-wrapper furniture__menu d-none d-lg-block">
                                <div class="main-menu">
                                    <nav id="mobile-menu">
                                        <ul>
                                            <li><a href="/url/usermanage">管理员主页</a></li>
                                            <li class="has-dropdown"><a href="/url/usermanage">管理功能</a>
                                                <ul class="submenu">
                                                    <li><a href="/url/usermanage">用户管理</a></li>
                                                    <li><a href="/url/promanage">商品管理</a></li>
                                                    <li><a href="/url/ordermanage">订单管理</a></li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<main>
    <div class="breadcrumb__area theme-bg-1 p-relative z-index-11 pt-95 pb-95">
        <div class="breadcrumb__thumb" data-background="../../imgs/bg/breadcrumb-bg.jpg"></div>
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-xxl-12">
                    <div class="breadcrumb__wrapper text-center"><h2 class="breadcrumb__title">商品管理</h2>
                        <div class="breadcrumb__menu">
                            <nav>
                                <ul>
                                    <li><span><a href="/url/usermanage">主页</a></span></li>
                                    <li><span>商品管理</span></li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="cart-area section-space">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <form id="info-form">
                        <div class="row">
                            <div class="form-group col-md-6">
                                <label>商品id（自动生成）</label>
                                <input required="" class="form-control square" name="proid" readonly placeholder="商品id（自动生成）"
                                       type="text" :value="product != null ? product.proid : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>商品名称</label>
                                <input required="" class="form-control square" name="name" placeholder="商品名称"
                                       type="text" :value="product != null ? product.name : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>商品副标题</label>
                                <input required="" class="form-control square" name="subtitle" placeholder="商品副标题"
                                       type="text" :value="product != null ? product.subtitle : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>产品主图（单张图片）</label><br>
                                <input type="file" name="imgfile" accept="image/jpeg, image/png, image/jpg">
                                <img v-if="product.mainimage != null" :src="product.mainimage" alt="#" width="80px" height="80px">
                            </div>
                            <div class="form-group col-md-6">
                                <label>商品原价</label>
                                <input required="" class="form-control square" name="price" placeholder="商品原价"
                                       type="text" :value="product != null ? product.price : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>其他图片（多张图片）</label><br>
                                <input type="file" name="filelist" accept="image/jpeg, image/png, image/jpg" multiple>
                                <img v-for="item in product.subimagesList" :src="item" width="80px" height="80px" class="mr-5">
                            </div>
                            <div class="form-group col-md-6">
                                <label>优惠价格</label>
                                <input required="" class="form-control square" name="disprice" placeholder="优惠价格"
                                       type="text" :value="product != null ? product.disprice : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>库存数量</label>
                                <input required="" class="form-control square" name="stock" placeholder="库存数量"
                                       type="text" :value="product != null ? product.stock : ''">
                            </div>
                            <div class="form-group col-md-6">
                                <label>商品状态</label>
                                <select class="form-control" name="status" v-model="status" style="height: 65px;font-size: 15px;padding-left: 26px">
                                    <option value="1">在售</option>
                                    <option value="2">下架</option>
                                </select>
                            </div>
                            <div class="form-group col-md-12">
                                <label>长文描述</label>
                                <textarea class="form-control" style="min-height: 125px;font-size: 15px;padding: 26px;"
                                          name="description" cols="30" rows="9" placeholder="长文描述..."
                                          v-text="product != null ? product.description : ''"></textarea>
                            </div>
                            <div class="col-md-12" style="margin-top: 10px">
                                <button type="button" class="btn submit border" style="font-size: 20px; padding: 10px 30px;background-color: #b18b5e;color: white"
                                        name="submit" value="Submit" v-on:click="saveProduct()">保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</main>
<footer class="footer-bg">
    <div class="footer-area pt-100 pb-20">
        <div class="footer-style-4">
            <div class="container">
                <div class="footer-grid-3">
                    <div class="footer-widget-4">
                        <div class="footer-logo mb-35"><a href="/url/index"><img
                                src="../../imgs/furniture/logo/logo-light.svg" alt="image bnot found"></a></div>
                        <p>汇聚万千好书，点亮智慧之光，我们的书店网站，您的阅读天堂！</p>
                        <div class="theme-social"><a class="furniture-bg-hover" href="#"><i
                                class="fa-brands fa-facebook-f"></i></a><a class="furniture-bg-hover" href="#"><i
                                class="fa-brands fa-twitter"></i></a><a class="furniture-bg-hover" href="#"><i
                                class="fa-brands fa-linkedin-in"></i></a><a class="furniture-bg-hover" href="#"><i
                                class="fa-brands fa-instagram"></i></a></div>
                    </div>
                    <div class="footer-widget-4">
                        <div class="footer-widget-title"><h4>服务</h4></div>
                        <div class="footer-link">
                            <ul>
                                <li><a href="/url/register">注册</a></li>
                                <li><a href="/url/login">登录</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="footer-widget-4">
                        <div class="footer-widget-title"><h4>商城</h4></div>
                        <div class="footer-link">
                            <ul>
                                <li><a href="/url/prolist">图书选购</a></li>
                                <li><a href="/url/cart">购物车</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="footer-widget footer-col-4">
                        <div class="footer-widget-title"><h4>联系方式</h4></div>
                        <div class="footer-info mb-35">
                            <div class="footer-info-item d-flex align-items-start pb-15 pt-15">
                                <div class="footer-info-icon mr-20"><span><i
                                        class="fa-solid fa-location-dot furniture-icon"></i></span></div>
                                <div class="footer-info-text"><a class="furniture-clr-hover" target="_blank"
                                                                 href="">北京市东城区藏经馆胡同17号1幢A103室</a></div>
                            </div>
                            <div class="footer-info-item d-flex align-items-start">
                                <div class="footer-info-icon mr-20"><span><i
                                        class="fa-solid fa-phone furniture-icon"></i></span></div>
                                <div class="footer-info-text"><a class="furniture-clr-hover" href="tel:012-345-6789">4001066666-5</a></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <div class="footer-copyright-area b-t">
            <div class="footer-copyright-wrapper">
                <div class="footer-copyright-text"><p class="mb-0">© All Copyright 2024 by <a target="_blank"
                                                                                              class="furniture-clr-hover"
                                                                                              href="/url/index">Addina</a>
                </p></div>
                <div class="footer-payment d-flex align-items-center gap-2">
                    <div class="footer-payment-item mb-0">
                        <div class="footer-payment-thumb"><img src="../../imgs/icons/payoneer.png" alt=""></div>
                    </div>
                    <div class="footer-payment-item mb-0">
                        <div class="footer-payment-thumb"><img src="../../imgs/icons/maser.png" alt=""></div>
                    </div>
                    <div class="footer-payment-item">
                        <div class="footer-payment-thumb"><img src="../../imgs/icons/paypal.png" alt=""></div>
                    </div>
                </div>
                <div class="footer-conditions">
                    <ul>
                        <li><a class="furniture-clr-hover" href="#">经营许可</a></li>
                        <li><a class="furniture-clr-hover" href="#">隐私政策</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</footer>
<style>
    .cart-area .cart-plus, .cart-area .cart-minus {
        position: relative;
        width: 100%;
        height: 0;
        top: 0;
    }
</style>
<script src="../../js/jquery-3.6.0.min.js"></script>
<script src="../../js/waypoints.min.js"></script>
<script src="../../js/bootstrap.bundle.min.js"></script>
<script src="../../js/meanmenu.min.js"></script>
<script src="../../js/swiper.min.js"></script>
<script src="../../js/slick.min.js"></script>
<script src="../../js/magnific-popup.min.js"></script>
<script src="../../js/counterup.js"></script>
<script src="../../js/wow.js"></script>
<script src="../../js/ajax-form.js"></script>
<script src="../../js/beforeafter.jquery-1.0.0.min.js"></script>
<script src="../../js/main.js"></script>
<script src="../../js/vue.global.js"></script>
<script src="../../js/axios.min.js"></script>
</body>
<script>
    const app = {
        data() {
            return {
                product: {}
            }
        },
        methods: {
            saveProduct: function (id) {
                if (confirm("确认保存该条记录吗？")) {
                    let formData = new FormData($("#info-form")[0]);
                    axios.post('/product/create', formData)
                        .then((response) => {
                            if (response.data.code == 200) {
                                alert('保存成功')
                                setTimeout(location.href = '/url/promanage', 2000);
                            } else {
                                alert('保存失败')
                            }
                        })
                        .catch((error) => {
                            console.error(error);
                            alert('保存失败')
                        })
                }
            },
        },
        created() {
            let searchstr = location.search
            if (searchstr != '') {
                let params = new URLSearchParams(location.search);
                let id = params.get('id')
                let _this = this
                axios.get('/product/'+id)
                    .then((response) => {
                        _this.product = response.data.data
                        _this.status = _this.product.status
                    })
                    .catch((error) => {
                        console.error(error);
                        alert('初期化错误')
                    })
            }
        }
    }
    Vue.createApp(app).mount('body')
</script>
</html>